Relational database management systems (RDBMSs) store information in tables, where each piece of data is stored at a particular row and column. Information in a given row generally is associated with a particular object, and information in a given column generally relates to a particular category of information. For example, each row of a table may correspond to a particular employee, and the various columns of the table may correspond to employee names, employee social security numbers, and employee salaries. A user retrieves information from and makes updates to a database by interacting with a database application. The user's actions are converted into a query by the database application. The database application submits the query to a database server. The database server responds to the query by accessing the tables specified in the query to determine which information stored in the tables satisfies the query. The information that satisfies the query is retrieved by the database server and transmitted to the database application. Alternatively, a user may request information directly from the database server by constructing and submitting a query directly to the database server using a command line or graphical interface. Queries submitted to the database server must conform to the syntactical rules of a database query language. One popular database query language, known as the Structured Query Language (SQL), provides users a variety of ways to specify information to be retrieved from relational tables.
The Extensible Markup Language (XML) provides a convenient way to express information in a hierarchically structured format. An XML document is a document that conforms to the XML standard. An XML document is typically composed of a set of nodes arranged in a hierarchy. Each node of a XML document may be composed of a set of one or more tags, and each node may have a set of associated attributes. A node may also be associated with a portion of the text of the XML document.
For a variety of reasons, it is often advantageous to store XML-formatted information/documents within a relational database table. A relational table column can be configured to store XML-formatted information in a “native” format, such that the structure of the XML information is preserved, e.g., using an XMLType(document) type, or an XMLType(content) type. Only XMLType(document) type instances can be stored in an XMLType(document) type column, and only XMLType(content) type instances can be stored in an XMLType(content) type column.
Once a set of XML documents are stored within a database, it would be advantageous to use an XML query language to retrieve, from the database, those XML documents that match a set of search criteria. An XML query language is a language that allows an operation, such as a search, to be performed on one or more XML documents, to be expressed. Illustrative examples of an XML query language are XPath and XQuery.
When a SQL query is executed, the results are returned as a row set, which is a set of rows. In contrast, when an XQuery query is executed, the results are returned as an instance of XMLType(sequence) type. In XQuery terminology, the result of an XQuery is an instance of XQuery data model.
The problem with this approach is that developers need to know the semantics of XML, XPath, or XQuery to use these approaches to query the XML data. This is typically much less convenient than an approach that allows developers to use ordinary SQL.
To address this problem, the SQL/XML standard has been developed which enables XML to be queried from within SQL. One of the constructs supported by this standard is the XMLTABLE( ) construct. The XMLTABLE( ) construct is a table function that projects a relational view of data residing in XML documents. Certain applications can be written entirely as SQL queries against these XMLTABLE( ) based relational views. Such an approach hides the application developers from knowing anything about XML, XPath, or XQuery. Once the relational views have been defined, it is simple to write SQL queries on these views.
Conventionally, these views are read-only views and therefore cannot be used to perform modifications or updates to the underlying data. One reason for this is because SQL/XML standard does not define a mechanism to update these views. Therefore, if the application desires to update certain fields within the XML, then it has to do a full document replacement or perform node level updates using XQuery Update or vendor-proprietary update operators.